<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/commons/meta.jsp" %>
	<script type="text/javascript">
		
	</script>
</head>

<body> 


<%@include file="/commons/top.jsp" %>
  	<div id="sub-header" class="twidth">
  	<div id="navsub">
		<div class="l"></div>
		<div class="r"></div>
		<div class="m">
		<div style="width:600px;float:left;">
			<a href="${ctx}">首页</a> → <a href="">免费发布工人信息</a>
		</div>
		</div>
	</div>
	
	<div id="middle">
    <div id="directory" class="mframe mR" style="width:724px;float:left;">
	  	<s:form action="/PublishInfo/save.do" method="post" theme="simple">
		<table class="formTable"  cellspacing="15" >
			<tr>
				<td colspan="2">
				<%@ include file="/commons/messages.jsp" %>
				免费发布工人信息			 
				</td>
			</tr>
			<tr>
				<td class="tdLabel"><font color="red">*</font>&nbsp;&nbsp;所在区域</td>
				<td style="white-space: normal;">
   					<s:radio name="cityId"   theme="simple" 
			   			id="cityId" list="cityList" listKey="cityId" 
			     		listValue="name" ></s:radio>
				</td>
			</tr>
			
			<tr>
				<td class="tdLabel"><font color="red">*</font>&nbsp;&nbsp;服务区域</td>
				<td style="white-space: normal;">
					<s:checkboxlist   name="serviceAreas"   theme="simple" 
			   			id="serviceAreas" list="cityList" listKey="cityId" 
			     		listValue="name" />
				</td>
			</tr> 
			
			<tr>
				<td class="tdLabel"><font color="red">*</font>&nbsp;&nbsp;类别</td>
				<td>
					<s:radio listKey="categoryId" listValue="categoryName"
					 	list="categoryList" name="categoryId" ></s:radio>
					 <%-- 	
   					<s:checkboxlist   tooltip="Choose your Friends" listKey="categoryId" listValue="categoryName"
					 	list="categoryList" name="categoryIds"/>--%>
				</td>
			</tr>
			<tr>
				<td class="tdLabel"><font color="red">*</font>&nbsp;&nbsp;姓名</td>
				<td style="height:40px"><s:textfield name="name" id="name" value="%{model.name}" cssClass="required" required="true" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel"><font color="red">*</font>&nbsp;&nbsp;地址</td>
				<td style="height:40px"><s:textfield name="address" id="address" value="%{model.address}" cssClass="required" cssStyle="width:240px" required="true" /></td>
			</tr>
			<tr>
				<td class="tdLabel"><font color="red" style="font-weight:bold;font-size:14px;">*</font>&nbsp;&nbsp;电话 </td>
				<td style="height:40px"><s:textfield id="phone" name="phone" cssClass="required" required="true" /></td>
			</tr>
			<tr>
				<td class="tdLabel"><font color="red" style="font-weight:bold;font-size:14px;">*</font>&nbsp;&nbsp;年龄 </td>
				<td style="height:40px">
				<s:textfield id="age" name="age" cssStyle="width:40px" cssClass="required validate-integer max-value-75 min-value-18" required="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				
				性别：<input type="radio" id="gender1" name="gender" value="1" checked /><label for="gender1">男</label>&nbsp;&nbsp;
				<input type="radio" id="gender0" name="gender" value="0" /><label for="gender0">女</label>
				</td>
			</tr>
			<tr>
				<td class="tdLabel"><font color="red" style="font-weight:bold;font-size:14px;">*</font>&nbsp;&nbsp;从事本工作年限 </td>
				<td style="height:40px"><s:textfield id="workAge" name="workAge" cssClass="required validate-integer max-value-60 min-value-0" required="true" /></td>
			</tr>
			<tr>
				<td class="tdLabel"><font color="red" style="font-weight:bold;font-size:14px;">*</font>&nbsp;&nbsp;个人说明 </td>
				<td style="height:100px"><s:textarea id="profile" name="profile" cssClass="required" cols="80" rows="5" required="true" /></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td align="left">
					<input id="submitButton" name="submitButton" type="submit" style="width:120px" value="确定" />
				</td>
			</tr>
		</table>
		</s:form>
    </div>
	
  	</div>
  	<jsp:include page="/commons/bottom.html"  flush="true"></jsp:include>
  </div>
  
<script>
	function doCheck(){
		var cityArray = document.getElementsByName("cityId");
		var serviceAreaArray = document.getElementsByName("serviceAreas");
		var categoryIdArray =document.getElementsByName("categoryId");
		var cityFlag = false;
		var serviceFlag = false;
		var categoryFlag = false;
		for(i=0;i<cityArray.length;i++){
			if(cityArray[i].checked==true){
				cityFlag = true;
				break;
			}
		}
		if(!cityFlag){
			alert("请选择所在区域");
			return false;
		}
		
		
		for(i=0;i<serviceAreaArray.length;i++){
			if(serviceAreaArray[i].checked==true){
				serviceFlag = true;
				break;
			}
		}
		if(!serviceFlag){
			alert("请选择服务区域");
			return false;
		}
		
		for(i=0;i<categoryIdArray.length;i++){
			if(categoryIdArray[i].checked==true){
				categoryFlag = true;
				break;
			}
		}
		if(!categoryFlag){
			alert("请选择类别");
			return false;
		}
		
		return true;
	}
	
	new Validation(document.forms[0],{onSubmit:true,onFormValidate : function(result,form) {
		var finalResult = result;
		
		//在这里添加自定义验证
		return doCheck();
		
		return disableSubmit(finalResult,'submitButton');
	}});
	
  	document.getElementById("indexPage").className="thisclass";
  	

  </script>
</body>
</html>